/*
 * @作者: kerwin
 * @公众号: 大前端私房菜
 */
import React, { Component } from "react";

export default class App extends Component {
  // myusername = React.createRef() 若是写为受控得在状态里写state

  state = {
    username: "kerwin",
  };
  render() {
    return (
      <div>
        <h1>登录页</h1>
        <input
          type="text"
          value={this.state.username}
          onChange={(e) => {
            console.log("onChange", e.target.value);

            this.setState({
              username: e.target.value,
            });
          }}
        />

        <button
          onClick={() => {
            alert(this.state.username);
          }}
        >
          登录
        </button>
        <button
          onClick={() => {
            this.setState({
              username: "",
            });
          }}
        >
          重置
        </button>

        {/* <Child myvalue={this.state.username}/> */}
      </div>
    );
  }
}
